package sivan.观察者模式;

import sivan.domain.Student;

/**
 * Created by sivan on 2019/2/28.
 */
public class StudentObserver implements Observer {

    private Student student;
    private Subject subject;

    public StudentObserver(Student student, Subject subject) {
        this.student = student;
        this.subject = subject;
        this.subject.addObserver(this);
    }

    public StudentObserver() {
    }

    @Override
    public void update(String info) {
        System.out.println(student.toString() + "获取到信息：" + info);
    }

    @Override
    public void delete() {
        this.subject.deleteObserver(this);
    }
}
